package com.eras.shoes.ui

import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.TextView
import androidx.activity.ComponentActivity
import com.eras.shoes.R
import com.eras.shoes.utils.ToastUtils
import com.google.zxing.integration.android.IntentIntegrator

class InsoleTwoActivity : ComponentActivity(), View.OnClickListener {

    private val btnBack: TextView by lazy { findViewById<TextView>(R.id.tv_insole_back_two) }
    private val btnScanCodeOne: Button by lazy { findViewById<Button>(R.id.btn_two_scan_code_one) }
    private val tvSerialNumberOne: TextView by lazy { findViewById<TextView>(R.id.tv_two_serial_number_one) }
    private val tvSerialNumberComparisonResultOne: TextView by lazy { findViewById<TextView>(R.id.tv_two_serial_number_comparison_result_one) }
    private val btnPutinComparisonOne: Button by lazy { findViewById<Button>(R.id.btn_two_putin_comparison_one) }
    private val tvPutinComparisonResultOne: TextView by lazy { findViewById<TextView>(R.id.tv_two_putin_comparison_result_one) }
    private val tvSaveResultOne: TextView by lazy { findViewById<TextView>(R.id.tv_save_result_one) }
    private val btnScanCodeTwo: Button by lazy { findViewById<Button>(R.id.btn_scan_code_two) }
    private val tvSerialNumberTwo: TextView by lazy { findViewById<TextView>(R.id.tv_serial_number_two) }
    private val tvSerialNumberComparisonResultTwo: TextView by lazy { findViewById<TextView>(R.id.tv_serial_number_comparison_result_two) }
    private val btnPutinComparisonTwo: Button by lazy { findViewById<Button>(R.id.btn_putin_comparison_two) }
    private val tvPutinComparisonResultTwo: TextView by lazy { findViewById<TextView>(R.id.tv_putin_comparison_result_two) }
    private val btnSaveTwo: Button by lazy { findViewById<Button>(R.id.btn_save_two) }
    private val tvSaveResultTwo: TextView by lazy { findViewById<TextView>(R.id.tv_save_result_two) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.layout_insole_two)
        btnBack.setOnClickListener(this)
        btnScanCodeOne.setOnClickListener(this)
        btnPutinComparisonOne.setOnClickListener(this)
        btnScanCodeTwo.setOnClickListener(this)
        btnPutinComparisonTwo.setOnClickListener(this)
        btnSaveTwo.setOnClickListener(this)

    }

    override fun onClick(p0: View?) {
        val toast = ToastUtils()
        when (p0?.id){
            R.id.tv_insole_back_two -> {
                finish()
            }
            R.id.btn_two_scan_code_one -> {
                // 扫描二维码
                IntentIntegrator(this).initiateScan()
            }
            R.id.btn_two_putin_comparison_one -> {
                toast.show(this, "鞋垫1入库比对")
            }
            R.id.btn_scan_code_two -> {
                // 扫描二维码
                IntentIntegrator(this).initiateScan()
            }
            R.id.btn_putin_comparison_two -> {
                toast.show(this, "鞋垫2入库比对")
            }
            R.id.btn_save_two -> {
                toast.show(this, "保存鞋垫1和鞋垫2序列号")
            }

        }
    }

}